package com.woniu.register.service.impl;

import com.github.pagehelper.PageHelper;
import com.woniu.register.VO.FileVo;
import com.woniu.register.dto.DirDTO;
import com.woniu.register.dto.FileDTO;
import com.woniu.register.mapper.DirectoryMapper;
import com.woniu.register.mapper.OwnerMapper;
import com.woniu.register.mapper.ProposerMapper;
import com.woniu.register.service.PigeonholeService;
import com.woniu.register.VO.FileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ：zhulongxing
 * @date ：Created in 2022/12/6 19:01
 * @description：
 * @modified By：
 * @version: $
 */
@Service
public class PigeonholeServiceImpl implements PigeonholeService {
    @Autowired
    private ProposerMapper proposerMapper;
    @Autowired
    private OwnerMapper ownerMapper;
    @Autowired
    private DirectoryMapper directoryMapper;
    public List<FileVo> selectAll(FileDTO fileDTO) {
        PageHelper.startPage(fileDTO.getPageNow(),fileDTO.getPageSize(),true);
        return proposerMapper.selectAll(fileDTO);
    }

    @Override
    public List<FileVo> selectAllS(FileDTO fileDTO) {
        PageHelper.startPage(fileDTO.getPageNow(),fileDTO.getPageSize(),true);
        return proposerMapper.selectAllTitle(fileDTO);
    }

    @Override
    @Transactional
    public int updateAndInsert(DirDTO dto) {
        directoryMapper.insertNew(dto);
        ownerMapper.updateNew(dto);
        return 1;
    }
}
